package com.liangzdemo.observertwo;

import android.util.Log;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by liangz on 2018/3/25.
 */

public class MyObserver implements Observer {

    private int id;
    private MyPerson myPerson;

    public MyObserver(int id) {
        Log.d("coco_observer_two","我是观察者---->" + id);
        this.id = id;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public MyPerson getMyPerson() {
        return myPerson;
    }



    @Override
    public void update(Observable observable, Object o) {
        Log.d("coco_observer_two","观察者---->" + id + "得到更新");
        this.myPerson = (MyPerson) observable;
    }
}
